package two_pointer.leetcode_11;

public class TwoPointer {
    public int maxArea(int[] height) {
        int maxWater = 0;
        int left = 0;
        int right = height.length - 1;
        while (left < right) {
            //记录水量的最大值
            maxWater = Math.max(maxWater, Math.min(height[left], height[right]) * (right - left));

            //选择移动高度较小的边
            if (height[left] < height[right]) {
                left++;
            } else {
                right--;
            }
        }
        return maxWater;
    }
}
